package com.smartwebx.ha.web.gis.module.screen;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Param;
import com.smartwebx.ha.util.IsoProperty;
import com.smartwebx.ha.util.KmlProperty;
import com.smartwebx.ha.web.admin.common.HaUserSys;
import com.smartwebx.ha.web.util.kml.GetAreaKml;
import com.smartwebx.ha.web.util.kml.GetIsoLine;
import com.smartwebx.ha.web.util.kml.GetIsoSurface;
import com.smartwebx.ha.web.util.kml.HttpRequest;
/**
 * 等值线、面
 * 
 * @param drawType(线或面)
 *            绘制类型
 * @param sdate(查询开始时间)
 *            可选
 * @param edate (结束时间)  
 * 			  可选
 * @param rainLevel(绘制级别)    
 * @param rainData(雨量点数据)
 * @return
 * @throws ParseException
 */
public class AjaxMakeIso extends BasicScreen {
	@Autowired
	private HttpSession session;
	public List<IsoProperty> getIso(@Param("drawType") String drawType,
			@Param("sdate") String sdate, @Param("edate") String edate,
			@Param("rainLevel") String rainLevel,@Param("rainData") String rainData) throws IOException {
		GetIsoLine getIsoLine = new GetIsoLine();
		GetIsoSurface getIsoSurface = new GetIsoSurface();
		HaUserSys user = (HaUserSys) session.getAttribute("haUser");
		String url="http://10.32.36.36/hgp/devapi/JiangSuRealTimeRainContour";
		StringBuffer sb = new StringBuffer();
		sb.append("borderId=").append(user.getCode()).append("&");
		sb.append("sdate=").append("201512178").append("&");
		sb.append("edate=").append("201512188").append("&");
		sb.append("rainLevel=").append(rainLevel).append("&");
		sb.append("rainData=").append(rainData); 
		String param=sb.toString();
		HttpRequest request = new HttpRequest();
		String str = request.sendPost(url, param);
		String dzx = str.substring(str.indexOf("<dzx>")+5, str.indexOf("</dzx>"));
		String dzm=str.substring(str.indexOf("<dzm>")+5, str.indexOf("</dzm>"));
		List<IsoProperty> list = new ArrayList<>();
		list.add(getIsoSurface.readIsoSurface(dzm));
		list.add(getIsoLine.readIsoLine(dzx));
		
		return list;

	}
}
